<template>
	<view class="container">
		<block>
			<view @click="toPage('/pagesA/pages/serviceUserList/serviceUserInfo?id='+item.id)"
				class="padding margin-sm bg-white flex justify-start radius10" v-for="(item,index) in list"
				:key='index'>
				<image :src="item.logo" mode="" class="round cu-avatar"></image>
				<!-- @click.stop="toPage('/filePage/pages/detail-or-order/detail-or-order')" -->
				<view class="margin-left-sm f-grow1">
					<view class="flex justify-between align-center">
						<view class="text-bold text-181818 text-xl">
							{{item.shopName}}
						</view>

					</view>
					<view class="flex  justify-between align-center text-sm text-666 margin-top-sm">
						<view class="flex align-center text-sm text-666">
							<view>
								工人数量<text class="text-15 margin-left-xs">{{item.workerCount}}</text>
							</view>
							<view class="margin-left">
								工单数量<text class="text-15 text-FF3636 margin-left-xs"> {{item.serviceOrderCount}}</text>
							</view>
						</view>
					</view>
					<view class="flex justify-between align-center text-sm text-999" style="margin-top: 60rpx;">
						<view class="">
							创建时间 {{item.createTime}}
						</view>
						<view class="margin-left">
							电话:{{item.userMobile}}
						</view>
					</view>
				<view class="margin-top flex justify-end align-center">
					<button@click.stop="submit(item)"
						class="bg-color text-13 text-white btn round">
						邀请
					</button>
				</view>
				</view>
			</view>
		</block>

		<uni-load-more :status="loading" />
	</view>
</template>

<script>
	import BetterPull from "@/common/libs/BetterPull";
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = "loading";
					// let param;
					// 	this.url = this.$api.getMyShopUser
					// 	param = {
					// 		pageNum: page,
					// 		pageSize: 10,
					// 		noParentFlag: 1
					// 	}
					const [err, res] = await this.$get(
						this.$api.getMyShopUser,
						{
							pageNum: page,
							pageSize: 10,
							noParentFlag: 1,
							shopType:1
						}
					);
					if (res) {
						// console.log(res)
						var data = res.data.list;
						// this.total = res.data.total;
						done(data);
						if (data.length < 10) {
							this.loading = "noMore";
						} else {
							this.loading = "more";
						}
						// console.log(this.loading)
					}
					if (err) {
						done([]);
						this.loading = "noMore";
					}
				},
			}),
		],
		onLoad(options) {
			if(options.shopCenterId) this.shopCenterId = options.shopCenterId
		},
		data() {
			return {
				baseUrl: this.$config.baseUrl,
				loading: 'more',
				shopId: '',
				shopCenterId: ''
				
			};
		},
		methods: {
			toPage(url) {
				console.log(url)
				this.$util.openNewPage(url)
			},
			submit(item) {
				const that = this
				uni.showModal({
					content: '你确定邀请该服务商吗',
					success: function(res) {
						if (res.confirm) {
							// const data = {
							// 	userId: uni.getStorageSync('userId'),
							// 	shopId: item.id,
							// 	workerType: 1
							// }
							that.$get(that.$api.applyForCenter, {
								shopCenterId:that.shopCenterId,
								shopId:item.id
							}).then(res => {
								const [err, rs] = res
								if (rs) {
									that.$util.msg(rs.message)
									that.Refresh()
								}
							})



						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}

		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		padding: 4rpx;

		.tab {
			width: 350rpx;
			padding: 16rpx;
		}

		.on {
			background: #fff;
			color: #ED7200;
			font-weight: bold;
		}
	}

	.footer {
		position: fixed;
		left: 20rpx;
		right: 20rpx;
		bottom: 98rpx;

		image {
			width: 48rpx;
			height: 48rpx;
		}
	}

	.btn {
		padding: 20rpx 50rpx;
	}
</style>
